package cn.phecda.boot.tenant.test.database.jpa;

import cn.phecda.boot.data.core.entity.DataStatus;
import cn.phecda.boot.data.jpa.support.CommonJpaRepository;

import java.util.concurrent.ThreadLocalRandom;

/**
 * <p> TODO </p>
 *
 * @author : wanpinwei
 */
public interface PersonJpaJpaRepository extends CommonJpaRepository<PersonJpaEntity, String> {
    default PersonJpaEntity named(String name) {
        PersonJpaEntity entity =  new PersonJpaEntity(name);

        ThreadLocalRandom random = ThreadLocalRandom.current();
        if (random.nextBoolean()) {
            entity.setReserved(true);
            entity.setDataStatus(DataStatus.DISABLE);
        }
        return entity;
    }

}
